package thirdwork.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.mysql.cj.Session;

import thirdwork.dao.EmployeeDao;
import thirdwork.dao.impl.EmployeeImpl;
import thirdwork.domain.Employee;

/**
 * Servlet implementation class UpdateEmployee
 */
@WebServlet("/UpdateEmployee")
public class UpdateEmployee extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String id = req.getParameter("empid");
		int eid = Integer.parseInt(id);
		EmployeeDao empdao = new EmployeeImpl();
		Employee employee = empdao.findById(eid);
		HttpSession session = req.getSession();
		session.setAttribute("employee", employee);
		session.setAttribute("empid", eid);
		resp.sendRedirect(req.getContextPath() + "/updateEmployee.jsp");
	}
}
